#ifndef RECORDSLAMROUTE_H
#define RECORDSLAMROUTE_H
#include <QDateTime>
#include <QDialog>
#include <QFile>
#include <QMenu>
#include <QMessageBox>
#include <QTextEdit>
#include <QTextStream>
#include <QTimer>

#include "param.h"
#include "utility.h"
namespace Ui {
class RecordSlamRoute;
}

class RecordSlamRoute : public QDialog {
  Q_OBJECT

 public:
  struct PointInfo {
    int ID;
    double X;
    double Y;
    int Type;
    QList<QString> Childs;
  };

  explicit RecordSlamRoute(QWidget* parent = nullptr);
  void showTips(const QString& str);
  ~RecordSlamRoute();
  void keyPressEvent(QKeyEvent* e);

 signals:
  void sigSendKyeEvent(QKeyEvent* e);

 private slots:
  void on_pushButton_close_clicked();
  void slt50msTimer();
  void sltRecvCurPoint(const int& x, const int& y, const double&);
  void sltRecvQrcodePoint(const Point& qrcode, const int& id);

  void on_pushButton_record_p2p_clicked();

  void on_pushButton_route_clicked();

  void on_pushButton_clear_msg_clicked();

  void on_pushButton_record_cur_point_clicked();

  void on_pushButton_download_route_file_clicked();

  void on_pushButton_record_exit_point_clicked();

 private:
  bool readPointData();
  bool writePointInfoList();
  bool writeExitPointInfoList();
  void writeToSlamPointCSV();
  QList<PointInfo> PointInfolist;
  Ui::RecordSlamRoute* ui;
  Point cur_point;
  Point qrcodePoint;
  int qrcode_tag_id = 0;
  QFile* routeFile = nullptr;
  bool is_open_record = false;
  //路线管理
  QTextEdit* textedit;
};

#endif  // RECORDSLAMROUTE_H
